<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <header class="aui-bar aui-bar-nav main-header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            检测单列表
        </div>
    </header>
    <script id="chkBillTemp" type="text/x-dot-template">

        {{~ it:value:index}}
        <li class="aui-list-item" >
            <div class="aui-media-list-item-inner" style='position: relative;'>
                <div class="aui-list-item-inner " >
                    <div class="aui-list-item-text">
                        <div class="aui-list-item-title aui-font-size-14">
                            检测单号:{{= it[index].code }}
                        </div>
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        检测类型:{{= it[index].chkTypeName }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        物料编码:{{= it[index].mrlCode }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        物料名称:{{= it[index].mrlName }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        物料规格:{{= it[index].specification }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        审核状态:{{= it[index].processStateName }}
                    </div>
                    <div class="aui-list-item-text aui-font-size-12">
                        处理结果:{{= it[index].chkResultName }}
                    </div> 
                    <div class="aui-list-item-text aui-font-size-12">
                        来料总数:{{= it[index].lotQty }}
                    </div> 
                    <div class='aui-list-item-right aui-btn' 
                        style='background:#d0d0d0;color:#000000;' 
                        onclick="setChkBill('{{= it[index].sysid }}','{{= it[index].code }}','{{= it[index].mrlCode }}','{{= it[index].mrlName }}','{{= it[index].opCode }}','{{= it[index].opName }}','{{= it[index].chkTypeName }}');"
                    >
                        处理
                    </div> 
                    <div class='aui-list-item-right aui-btn' 
                        style='background:#03a9f4;color:#000000;' 
                        onclick="goDetailBHPge('{{= it[index].ext09 }}')"
                    >
                        质量报告
                    </div> 
                </div>
              
                 
            </div>
        </li>
        <li>
            
        </li>
        {{~}}

    </script>
    <div class="aui-bar aui-bar-nav sub-header"></div>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="white_background">
            <div class="aui-form" style="margin-top:15px;">
                <div class="aui-content aui-margin-b-15">
                    <ul class="aui-list aui-form-list">
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-label">发货单号</div>
                                <div class="aui-list-item-input">
                                    <input type="text" placeholder="选择/扫描 发货单号" id="ext09" value=""
                                        onclick="getIdSelector();" />
                                </div>
                                <i class="aui-input-addon aui-iconfont aui-icon-scan "
                                    style="padding-right:10px;font-size: 1.6rem" onclick="doScan('ext09');"></i>
                            </div>
                        </li>
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-label">物料编码</div>
                                <div class="aui-list-item-input">
                                    <input type="text" placeholder="请输入物料编码" id="mrlCode" value=""
                                        onclick="getIdSelector();" />
                                </div>
                            </div>
                        </li>
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-label">规格</div>
                                <div class="aui-list-item-input">
                                    <input type="text" placeholder="请输入规格" id="drawing" value=""
                                        onclick="getIdSelector();" />
                                </div>
                            </div>
                        </li>
                        <li class="aui-list-item">
                            <div class="aui-list-item-inner">
                                <div class="aui-list-item-label">箱码</div>
                                <div class="aui-list-item-input">
                                    <input type="text" placeholder="选择/扫描 箱码" id="tm" value=""
                                        onclick="getIdSelector();" />
                                </div>
                                <i class="aui-input-addon aui-iconfont aui-icon-scan "
                                    style="padding-right:10px;font-size: 1.6rem" onclick="doScan('tm');"></i>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="aui-btn aui-btn-info aui-btn-block" style="margin:0 5%;width: 90%;" onclick="doSearch()">查询</div>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="chkBillList">

        </ul>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var boxnum = "";
    var chkBillTypeNew = ""
    apiready = function () {
        $("#tm").focus();
        idSelector = "tm";
        doSearch();
        chkBillTypeNew = "LLJY"
    };
    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //扫描
    function doScan(inputId) {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {

            //1：箱号
            if (inputId == 'tm') {
                $("#tm").blur();
                //箱号
                $("#tm").val(ret);
                doSearch();
            } else if (inputId == 'ext09') {
                $("#ext09").blur();
                //箱号
                $("#ext09").val(ret);
                doSearch();
            }
        });
    }

    //箱号监听回车事件
    $("#tm").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            if (tm != null && tm != "" && tm != undefined) {
                doSearch();
            }
        }
    });

    //发货单号监听回车事件
    $("#ext09").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            if (tm != null && tm != "" && tm != undefined) {
                doSearch();
            }
        }
    });
    //工单号扫描回车
    $("#mrlCode").on('keypress', function (e) {
        var keycode = e.keyCode;
        var tm = $(this).val();
        if (keycode == '13') {
            $("#mrlCode").val(tm);
            doSearch();
        }
    });

    //查询检测单
    function doSearch() {

        //审核状态：0未处理，3处理中，7已处理，8已确认，9已取消
        var processState = "0";
        //检测单类型（1-材料检测单，2-在制品检测单，3-5S检测单，4-4W检测单，5-设备检测单）
        var chkBillType = 'LLJC';
        //箱号
        var tm = $("#tm").val();
        //物料号
        var mrlCode = $("#mrlCode").val();
        //规格
        var drawing = $("#drawing").val();
        //发货单号
        var ext09 = $("#ext09").val();
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getChkBill";
        var data = {
            values: {
                processState: processState,
                chkBillType: chkBillType,
                drawing: drawing,
                tm: tm,
                mrlCode: mrlCode,
                un: un,
                ext09: ext09,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    var evaluation = doT.template($api.dom('#chkBillTemp').innerHTML);
                    $api.dom('#chkBillList').innerHTML = evaluation(list);
                    boxnum = myobj.boxnum
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //选则返回函数
    function setChkBill(id, code, mrlCode, mrlName, opCode, opName, chkTypeName) {
        //api.closeWin();
        api.openWin({
            name: 'qcmChkBillDeal-LLJY',
            url: 'qcmChkBillDeal-LLJY.html',
            pageParam: {
                chkBillCode: code,
                name: "qcmSelectChkBill-LLJY",
            }
        });
    }
    function reset() {
        doSearch();
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
    //文件
    function goDetailBHPge(ext09) {
        var ext09 = ext09
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/fileInfoGet";
        var data = {
            values: {
                ext09: ext09,
                un: un,
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0' && myobj.list.length > 0) {
                    var list = eval(myobj.list);
                    api.openWin({
                        name: 'fileInfoShow',
                        url: 'fileInfoShow.html',
                        pageParam: {
                            list: list,
                            name: "qcmSelectChkBill-LLJY",
                        }
                    });
                    //setTable(list)
                    // console.log(list[0].docid,list[0].file_name)
                    //console.log(list[0].docid,list[0].file_original_name)
                    //openFile(list[0].docid,list[0].file_original_name)
                } else {
                    api.toast({
                        msg: '该检测单不存在质量报告！',
                        duration: 3000
                    });
                }
            }
        });
    }

</script>

</html>